<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv="Expires" CONTENT="0">
<meta http-equiv="Cache-Control" CONTENT="no-cache">
<meta http-equiv="Pragma" CONTENT="no-cache">
<title>支付方式</title>
<link rel="stylesheet" type="text/css" href="../easyui/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="../easyui/themes/icon.css">
<link rel="stylesheet" type="text/css" href="../easyui/demo/demo.css">
<script type="text/javascript" src="../easyui/jquery.min.js"></script>
<script type="text/javascript" src="../easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="../uploadjs/vendor/jquery.ui.widget.js"></script>
<script type="text/javascript" src="../uploadjs/jquery.iframe-transport.js"></script>
<script type="text/javascript" src="../uploadjs/jquery.fileupload.js"></script>
<script type="text/javascript" src="../js/auth.js"></script>
</head>
<body class="easyui-layout">
<div data-options="region:'north',border:false" style="height:100px;background:#B3DFDA;padding:10px">
<div style="float:right;clear:both;margin-top:15px;margin-right:20px">
	<a href="javascript:logout()">注销</a>
	</div>
	<h2>蛋糕商城Rust版</h2>
	<h3>从2025为公众服务</h3>
</div>
<div data-options="region:'west',split:true,title:'主菜单'" style="width:180px;padding:0px;">
<div onclick="window.location='../pages/index.html'" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">主页</div><div class="menu-icon icon-add"></div></div>
<div onclick="window.location='../custpages/admin/index.html'" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">蛋糕商城后台</div><div class="menu-icon icon-add"></div></div>
<div onclick="window.location='../pages/goodses.html'" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">商品</div><div class="menu-icon icon-add"></div></div>
<div onclick="window.location='../pages/custorders.html'" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">订单</div><div class="menu-icon icon-add"></div></div>
<div onclick="window.location='../pages/paytypes.html'" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">支付方式</div><div class="menu-icon icon-add"></div></div>
<div onclick="window.location='../pages/statuses.html'" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">状态</div><div class="menu-icon icon-add"></div></div>
<div onclick="window.location='../pages/orderitems.html'" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">订单项</div><div class="menu-icon icon-add"></div></div>
<div onclick="window.location='../pages/goodstypes.html'" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">类型</div><div class="menu-icon icon-add"></div></div>
<div onclick="window.location='../pages/recommends.html'" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">推荐</div><div class="menu-icon icon-add"></div></div>
<div onclick="window.location='../pages/roles.html'" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">角色</div><div class="menu-icon icon-add"></div></div>
<div onclick="window.location='../pages/permissions.html'" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">许可</div><div class="menu-icon icon-add"></div></div>
<div onclick="window.location='../pages/users.html'" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">用户</div><div class="menu-icon icon-add"></div></div>
<div onclick="window.location='../pages/profile.html'" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">用户资料</div><div class="menu-icon icon-add"></div></div>
<div onclick="window.location='../pages/linkrolepermission.html'" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">链接角色许可</div><div class="menu-icon icon-add"></div></div>
<div onclick="window.location='../pages/linkuserrole.html'" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">链接用户角色</div><div class="menu-icon icon-add"></div></div>
</div>
<div data-options="region:'east',split:true,collapsed:true,title:'属性'" style="width:250px;overflow: hidden">
</div>
<div data-options="region:'south',border:false" style="height:40px;background:#A9FACD;padding:10px;text-align: center">
	蛋糕商城
</div>
<div data-options="region:'center',title:'Rust语言通用代码生成器：莲花　生成结果'">
<div title="搜索面板" class="easyui-panel" style="width:1600px;height:200px">
<form id="ffsearch" method="post">
<table cellpadding="5">
<tr>
<td>名字:</td><td><input  class='easyui-textbox' type='text' name='name' id='name' value='' data-options="required:false"/></td>
<td>活跃:</td><td><input  class='easyui-textbox' type='text' name='active' id='active' value='' data-options="required:false"/></td>
<td>&nbsp;</td>
<td>
		<select id="actionSelect" class='easyui-select' style="	width:90px;height:28px" onchange="toggleBtnShow(this.value)">
			<option value="1" selected>搜索</option>
			<option value="2">Excel过滤</option>
			<option value="3">PDF过滤</option>
		</select>
		</td><td>
		<div id="button-bar">
			<a href="#" class="easyui-linkbutton" style="display:block;width:110px;height:28px" data-options="iconCls:'icon-search'" onclick="searchPayTypesByFieldsByPage()">搜索</a>
			<a href="#" class="easyui-linkbutton" style="display:none;width:110px;height:28px" data-options="iconCls:'icon-filter'" onclick="filterPayTypesExcel()">Excel过滤</a>
			<a href="#" class="easyui-linkbutton" style="display:none;width:110px;height:28px" data-options="iconCls:'icon-filter'" onclick="filterPayTypesPDF()"">PDF过滤</a>
		</div>
		</td><td>
			<a href="javascript:void(0)" class="easyui-linkbutton" style="width:80px" data-options="iconCls:'icon-clear'"  onclick="clearForm('ffsearch');toggleBtnShow(1);$('#actionSelect').val(1)">清除</a>
</td>
</tr>
</table>
</form>
</div>
<table id="dg" class="easyui-datagrid" title="支付方式清单" style="width:1600px;height:600px" data-options="singleSelect:false,url:'../controller/payTypeController/searchPayTypesByFieldsByPage',queryParams:params,method:'post',pagination:true,toolbar:toolbar">
<thead>
<tr>
<th data-options="field:'id',checkbox:true">序号</th>
<th data-options="field:'name',width:80">名字</th>
<th data-options="field:'active',width:80">活跃</th>
</tr>
</thead>
</table>
<div class="easyui-window" title="新增支付方式" id="waddPayType" data-options="iconCls:'icon-save',modal:true,closed:true" style="width:800px;height:600px">
<div style="padding:10px 60px 20px 60px">
<form id="ff" method="post">
<table cellpadding="5">
<tr><td>名字:</td><td><input  class='easyui-textbox' type='text' name='name' id='name' value='' data-options="required:false"/></td></tr>
<tr><td>活跃:</td><td><input class='easyui-radio' type='radio' name='active' id='active' value='true' checked='true'/>True<input type='radio' class='easyui-radio' name='active' id='active' value='false'/>False</td></tr>
</table>
</form>
<div style="text-align:center;padding:5px">
<a href="javascript:void(0)" class="easyui-linkbutton" onclick="addPayType()">新增</a>
<a href="javascript:void(0)" class="easyui-linkbutton" onclick="clearForm('ff')">清除</a>
<a href="javascript:void(0)" class="easyui-linkbutton" onclick="$('#waddPayType').window('close')">取消</a>
</div>
</div>
<div class="easyui-window" title="编辑支付方式" id="wupdatePayType" data-options="iconCls:'icon-save',modal:true,closed:true" style="width:800px;height:600px">
<div style="padding:10px 60px 20px 60px">
<form id="ffedit" method="post">
<input  type='hidden' name='id' id='id' value=''/>
<table cellpadding="5">
<tr><td>名字:</td><td><input  class='easyui-textbox' type='text' name='name' id='name' value='' data-options="required:false"/></td></tr>
<tr><td>活跃:</td><td><input class='easyui-radio' type='radio' name='active' id='active' value='true' checked='true'/>True<input type='radio' class='easyui-radio' name='active' id='active' value='false'/>False</td></tr>
</table>
</form>
<div style="text-align:center;padding:5px">
<a href="javascript:void(0)" class="easyui-linkbutton" onclick="updatePayType()">编辑</a>
<a href="javascript:void(0)" class="easyui-linkbutton" onclick="$('#ffedit').form('clear');">清除</a>
<a href="javascript:void(0)" class="easyui-linkbutton" onclick="$('#wupdatePayType').window('close')">取消</a>
</div>
</div>
<div class="easyui-window" title="查看支付方式" id="wviewPayType" data-options="iconCls:'icon-save',modal:true,closed:true" style="width:800px;height:600px">
<div style="padding:10px 60px 20px 60px">
<form id="ffview" method="post">
<input  type='hidden' name='id' id='id' value=''/>
<table cellpadding="5">
<tr><td>名字:</td><td><input  class='easyui-textbox' type='text' name='name' id='name' value='' data-options="required:false"/></td></tr>
<tr><td>活跃:</td><td><input class='easyui-radio' type='radio' name='active' id='active' value='true' checked='true'/>True<input type='radio' class='easyui-radio' name='active' id='active' value='false'/>False</td></tr>
</table>
</form>
<div style="text-align:center;padding:5px">
<a href="javascript:void(0)" class="easyui-linkbutton" onclick="$('#wviewPayType').window('close')">关闭</a>
</div>
</div>
</div>
</body>
<script type="text/javascript">
var params = {};
var pagesize = 10;
var pagenum = 1;
var toolbar = [
{
	text:'查看',
	iconCls:'icon-search',
	handler:function(){
		var rows = $("#dg").datagrid("getChecked");
		if (rows == undefined || rows == null || rows.length == 0 ){
			$.messager.alert("警告","请选定一条记录！","warning");
			return;
		}
		if (rows.length > 1) {
			$.messager.alert("警告","请选定一条记录！","warning");
			return;
		}
		$("#ffview").find("#id").val(rows[0]["id"]);
		$("#ffview").find("#name").textbox("setValue",rows[0]["name"]);
		var checkboxs = $("#ffview").find("input[name='active']");
		for (var i=0;i<checkboxs.length;i++){
			if (checkboxs.get(i).value == ""+rows[0]["active"]) checkboxs.get(i).checked=true;
		}
		$('#wviewPayType').window('open');
	}
}
,
{
	text:'新增',
	iconCls:'icon-add',
	handler:function(){
		$('#waddPayType').window('open');
	}
}
,
{
	text:'编辑',
	iconCls:'icon-edit',
	handler:function(){
		var rows = $("#dg").datagrid("getChecked");
		if (rows == undefined || rows == null || rows.length == 0 ){
			$.messager.alert("警告","请选定一条记录！","warning");
			return;
		}
		if (rows.length > 1) {
			$.messager.alert("警告","请选定一条记录！","warning");
			return;
		}
		$("#ffedit").find("#id").val(rows[0]["id"]);
		$("#ffedit").find("#name").textbox("setValue",rows[0]["name"]);
		var checkboxs = $("#ffedit").find("input[name='active']");
		for (var i=0;i<checkboxs.length;i++){
			if (checkboxs.get(i).value == ""+rows[0]["active"]) checkboxs.get(i).checked=true;
		}
		$('#wupdatePayType').window('open');
	}
}
,
{
	text:'软删除',
	iconCls:'icon-remove',
	handler:function(){
		var rows = $("#dg").datagrid("getChecked");
		if (rows == undefined || rows == null || rows.length == 0 ){
			$.messager.alert("警告","请选定一条记录！","warning");
			return;
		}
		if (rows.length > 1) {
			$.messager.alert("警告","请选定一条记录！","warning");
			return;
		}
		var id = rows[0]["id"];
		softDeletePayType(id);
	}
}
,
{
	text:'激活',
	iconCls:'icon-tip',
	handler:function(){
		var rows = $("#dg").datagrid("getChecked");
		if (rows == undefined || rows == null || rows.length == 0 ){
			$.messager.alert("警告","请选定一条记录！","warning");
			return;
		}
		if (rows.length > 1) {
			$.messager.alert("警告","请选定一条记录！","warning");
			return;
		}
		var id = rows[0]["id"];
		activatePayType(id);
	}
}
,
{
	text:'克隆',
	iconCls:'icon-add',
	handler:function(){
		var rows = $("#dg").datagrid("getChecked");
		if (rows == undefined || rows == null || rows.length == 0 ){
			$.messager.alert("警告","请选定一条记录！","warning");
			return;
		}
		if (rows.length > 1) {
			$.messager.alert("警告","请选定一条记录！","warning");
			return;
		}
		var id = rows[0]["id"];
		clonePayType(id);
	}
}
,
{
	text:'删除',
	iconCls:'icon-remove',
	handler:function(){
		var rows = $("#dg").datagrid("getChecked");
		if (rows == undefined || rows == null || rows.length == 0 ){
			$.messager.alert("警告","请选定一条记录！","warning");
			return;
		}
		if ($.messager.confirm("警告","确认要删除选定记录吗？", function(data){
			if (data){
				if (rows.length > 1) {
					$.messager.alert("警告","请选定一条记录！","warning");
					return;
				}
				var id = rows[0]["id"];
				deletePayType(id);
			}
		}));
}
}
,
{
	text:'切换',
	iconCls:'icon-cut',
	handler:function(){
		var rows = $("#dg").datagrid("getChecked");
		if (rows == undefined || rows == null || rows.length == 0 ){
			$.messager.alert("警告","请选定一条记录！","warning");
			return;
		}
		if (rows.length > 1) {
			$.messager.alert("警告","请选定一条记录！","warning");
			return;
		}
		var id = rows[0]["id"];
		togglePayType(id);
	}
}
,
{
	text:'留一切换',
	iconCls:'icon-cut',
	handler:function(){
		var rows = $("#dg").datagrid("getChecked");
		if (rows == undefined || rows == null || rows.length == 0 ){
			$.messager.alert("警告","请选定一条记录！","warning");
			return;
		}
		if (rows.length > 1) {
			$.messager.alert("警告","请选定一条记录！","warning");
			return;
		}
		var id = rows[0]["id"];
		toggleOnePayType(id);
	}
}
,'-',
{
	text:'批软删除',
	iconCls:'icon-remove',
	handler:function(){
		var rows = $("#dg").datagrid("getChecked");
		if (rows == undefined || rows == null || rows.length == 0 ){
			$.messager.alert("警告","请选定记录！","warning");
			return;
		}
		var ids = "";
		for(var i=0;i<rows.length;i++){
			ids += rows[i]["id"];
			if (i < rows.length-1) ids += ",";
		}
		softDeleteAllPayTypes(ids);
	}
}
,
{
	text:'批激活',
	iconCls:'icon-tip',
	handler:function(){
		var rows = $("#dg").datagrid("getChecked");
		if (rows == undefined || rows == null || rows.length == 0 ){
			$.messager.alert("警告","请选定记录！","warning");
			return;
		}
		var ids = "";
		for(var i=0;i<rows.length;i++){
			ids += rows[i]["id"];
			if (i < rows.length-1) ids += ",";
		}
		activateAllPayTypes(ids);
	}
}
,
{
	text:'批克隆',
	iconCls:'icon-add',
	handler:function(){
		var rows = $("#dg").datagrid("getChecked");
		if (rows == undefined || rows == null || rows.length == 0 ){
			$.messager.alert("警告","请选定记录！","warning");
			return;
		}
		var ids = "";
		for(var i=0;i<rows.length;i++){
			ids += rows[i]["id"];
			if (i < rows.length-1) ids += ",";
		}
		cloneAllPayTypes(ids);
	}
}
,
{
	text:'批删除',
	iconCls:'icon-remove',
	handler:function(){
		var rows = $("#dg").datagrid("getChecked");
		if (rows == undefined || rows == null || rows.length == 0 ){
			$.messager.alert("警告","请选定记录！","warning");
			return;
		}
		if ($.messager.confirm("警告","确认要删除选定记录吗？",function(data){
			if (data){
				var ids = "";
				for(var i=0;i<rows.length;i++){
					ids += rows[i]["id"];
					if (i < rows.length-1) ids += ",";
				}
				deleteAllPayTypes(ids);
			}
		}));
	}
}
,
{
	text:'Excel导出',
	iconCls:'icon-sum',
	handler:function(){
		window.location.href="../controller/payTypeController/exportPayTypes";
	}
}
,
{
	text:'PDF导出',
	iconCls:'icon-print',
	handler:function(){
		window.location.href="../controller/payTypeController/exportPayTypesPDF";
	}
}
];
$(document).ready(function(){
checkAccessPayType();
$("#dg").datagrid("load");
});
function clearForm(formId){
$('#'+formId).form('clear');
}
function addPayType(){
	if ($("#ff").form("validate")) {
		$.ajax({
			type: "post",
			url: "../controller/payTypeController/addPayType",
			data: JSON.stringify({
			name:$("#ff").find("#name").val(),
			active:parseBoolean($("#ff").find("input[name='active']:checked").val()),
			}),
			dataType: 'json',
			contentType:"application/json;charset=UTF-8",
			success: function(data, textStatus) {
				if (data.success) {
					window.location.reload();
				}
				},
			complete : function(XMLHttpRequest, textStatus) {
			},
			error : function(XMLHttpRequest,textStatus,errorThrown) {
				alert("Error:"+textStatus);
				alert(errorThrown.toString());
			}
		});
	}
}

function updatePayType(){
	$.ajax({
		type: "post",
		url: "../controller/payTypeController/updatePayType",
		data: JSON.stringify({
			id:parseInt($("#ffedit").find("#id").val()),
			name:$("#ffedit").find("#name").val(),
			active:parseBoolean($("#ffedit").find("input[name='active']:checked").val()),
		}),
		dataType: 'json',
		contentType:"application/json;charset=UTF-8",
		success: function(data, textStatus) {
			if (data.success){
				$("#wupdatePayType").window('close');
				$("#dg").datagrid("load");
			}
		},
		complete : function(XMLHttpRequest, textStatus) {
		},
		error : function(XMLHttpRequest,textStatus,errorThrown) {
			alert("Error:"+textStatus);
			alert(errorThrown.toString());
		}
	});
}

function softDeletePayType(id){
	$.ajax({
		type: "post",
		url: "../controller/payTypeController/softDeletePayType",
		data: {
			"id":id
		},
		dataType: 'json',
		success: function(data, textStatus) {
			$("#dg").datagrid("load");
		},
		complete : function(XMLHttpRequest, textStatus) {
		},
		error : function(XMLHttpRequest,textStatus,errorThrown) {
			alert("Error:"+textStatus);
			alert(errorThrown.toString());
		}
	});
}

function activatePayType(id){
	$.ajax({
		type: "post",
		url: "../controller/payTypeController/activatePayType",
		data: {
			"id":id
		},
		dataType: 'json',
		success: function(data, textStatus) {
			$("#dg").datagrid("load");
		},
		complete : function(XMLHttpRequest, textStatus) {
		},
		error : function(XMLHttpRequest,textStatus,errorThrown) {
			alert("Error:"+textStatus);
			alert(errorThrown.toString());
		}
	});
}

function clonePayType(id){
	$.ajax({
		type: "post",
		url: "../controller/payTypeController/clonePayType",
		data: {
			"id":id
		},
		dataType: 'json',
		success: function(data, textStatus) {
			$("#dg").datagrid("load");
		},
		complete : function(XMLHttpRequest, textStatus) {
		},
		error : function(XMLHttpRequest,textStatus,errorThrown) {
			alert("Error:"+textStatus);
			alert(errorThrown.toString());
		}
	});
}

function deletePayType(id){
	$.ajax({
		type: "post",
		url: "../controller/payTypeController/deletePayType",
		dataType: 'json',
		data:{"id":id},
		success: function(data, textStatus) {
			$("#dg").datagrid("load");
		},
		complete : function(XMLHttpRequest, textStatus) {
		},
		error : function(XMLHttpRequest,textStatus,errorThrown) {
			alert("Error:"+textStatus);
			alert(errorThrown.toString());
		}
	});
}

function togglePayType(id){
	$.ajax({
		type: "post",
		url: "../controller/payTypeController/togglePayType",
		data: {
			"id":id
		},
		dataType: 'json',
		success: function(data, textStatus) {
			$("#dg").datagrid("load");
		},
		complete : function(XMLHttpRequest, textStatus) {
		},
		error : function(XMLHttpRequest,textStatus,errorThrown) {
			alert("Error:"+textStatus);
			alert(errorThrown.toString());
		}
	});
}

function toggleOnePayType(id){
	$.ajax({
		type: "post",
		url: "../controller/payTypeController/toggleOnePayType",
		data: {
			"id":id
		},
		dataType: 'json',
		success: function(data, textStatus) {
			$("#dg").datagrid("load");
		},
		complete : function(XMLHttpRequest, textStatus) {
		},
		error : function(XMLHttpRequest,textStatus,errorThrown) {
			alert("Error:"+textStatus);
			alert(errorThrown.toString());
		}
	});
}

function softDeleteAllPayTypes(ids){
	$.ajax({
		type: "post",
			url: "../controller/payTypeController/softDeleteAllPayTypes",
			data: {
				ids:ids
			},
			dataType: 'json',
			success: function(data, textStatus) {
				$("#dg").datagrid("load");
			},
			complete : function(XMLHttpRequest, textStatus) {
		},
		error : function(XMLHttpRequest,textStatus,errorThrown) {
			alert("Error:"+textStatus);
			alert(errorThrown.toString());
		}
	});
}

function activateAllPayTypes(ids){
	$.ajax({
		type: "post",
			url: "../controller/payTypeController/activateAllPayTypes",
			data: {
				ids:ids
			},
			dataType: 'json',
			success: function(data, textStatus) {
				$("#dg").datagrid("load");
			},
			complete : function(XMLHttpRequest, textStatus) {
		},
		error : function(XMLHttpRequest,textStatus,errorThrown) {
			alert("Error:"+textStatus);
			alert(errorThrown.toString());
		}
	});
}

function cloneAllPayTypes(ids){
	$.ajax({
		type: "post",
			url: "../controller/payTypeController/cloneAllPayTypes",
			data: {
				ids:ids
			},
			dataType: 'json',
			success: function(data, textStatus) {
				$("#dg").datagrid("load");
			},
			complete : function(XMLHttpRequest, textStatus) {
		},
		error : function(XMLHttpRequest,textStatus,errorThrown) {
			alert("Error:"+textStatus);
			alert(errorThrown.toString());
		}
	});
}

function deleteAllPayTypes(ids){
	$.ajax({
		type: "post",
		url: "../controller/payTypeController/deleteAllPayTypes",
		data: {
			ids:ids
		},
		dataType: 'json',
		success: function(data, textStatus) {
			$("#dg").datagrid("load");
		},
		complete : function(XMLHttpRequest, textStatus) {
		},
		error : function(XMLHttpRequest,textStatus,errorThrown) {
			alert("Error:"+textStatus);
			alert(errorThrown.toString());
		}
	});
}

function searchPayTypesByFieldsByPage(){
	params = {
		name:$("#ffsearch").find("#name").val(),
		active:parseBoolean($("#ffsearch").find("#active").val()),
	};
	$("#dg").datagrid({queryParams:params});
}

function filterPayTypesExcel(){
	params = {
		name:$("#ffsearch").find("#name").val(),
		active:parseBoolean($("#ffsearch").find("#active").val()),
	};
	var params0 = $.param(params);
	document.location.href = "../controller/payTypeController/filterPayTypesExcel?" + params0;
}

function filterPayTypesPDF(){
	params = {
		name:$("#ffsearch").find("#name").val(),
		active:parseBoolean($("#ffsearch").find("#active").val()),
	};
	var params0 = $.param(params);
	document.location.href = "../controller/payTypeController/filterPayTypesPDF?" + params0;
}

function checkAccessPayType(){
	$.ajax({
		type: "get",
		url: "../controller/payTypeController/checkAccessPayType",
		dataType: 'json',
		success: function(data, textStatus) {
			if (!data.success && data.noAuth){
				window.location.href="../login/noauth.html"
			}
		},
		complete : function(XMLHttpRequest, textStatus) {
		},
		error : function(XMLHttpRequest,textStatus,errorThrown) {
			alert("Error:"+textStatus);
			alert(errorThrown.toString());
		}
	});
}

function parseBoolean(val){
	if (val == undefined|| val == null) return false;
	var isInt = /^(-}+)?\d+$/.test(val);
	if (isInt&& val == "0") return false;
	else if (isInt&& val == "1") return true;
	else if (val.toLowerCase() == "false") return false;
	else if (val.toLowerCase() == "true") return true;
	else if (val.toLowerCase() == "f") return false;
	else if (val.toLowerCase() == "t") return true;
	else if (val.toLowerCase() == "n") return false;
	else if (val.toLowerCase() == "y") return true;
	else if (val.toLowerCase() == "no") return false;
	else if (val.toLowerCase() == "yes") return true;
	else return "";
}

function parseBooleanInt(val){
	var b = parseBoolean(val);
	if (b==undefined||b==null) return 0;
	else if (b==true) return 1;
	else return 0;
}

function parseIntNeg(val){
	if (isBlank(val) || parseInt(val) <= 0) return -1;
	else return parseInt(val);
}

function isBlank(val){
	if (val == undefined|| val == null || val == "" || val== "0" || val == 0) return true;
	else return false;
}

function checkRadioBoxValue(control,field,fieldvalue){
	var checkboxs = $("#"+control).find("input[name='"+field+"']");
	for (var i=0;i<checkboxs.length;i++){
		if (checkboxs.get(i).value == ""+fieldvalue) checkboxs.get(i).checked=true;
	}
}

function toggleBtnShow(index){
	$('#button-bar a').css('display','none');
	$('#button-bar a:nth-child('+(index)+')').css('display','block');
}

</script>
</html>
